package com.woniuxy.springbootpro.config;

import com.woniuxy.springbootpro.interceptor.FirstInterceptor;
import com.woniuxy.springbootpro.interceptor.SecondInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SecurityConfig {

    @Bean
    public SecondInterceptor secondInterceptor(){
        return new SecondInterceptor();
    }

    @Bean
    public WebMvcConfigurer webMvcConfigurer(){
        return new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(new FirstInterceptor()).addPathPatterns("/index.html");
                registry.addInterceptor(secondInterceptor()).addPathPatterns("/root/r1","/root/r2","/root/r3");
            }
        };
    }
}
